home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / xmsif140.zip / XMSTEST.H < prev    next >
C/C++ Source or Header  |  1991-12-08  |  6KB  |  190 lines

  1. /***************************************************************************
  2. *   xmstest.h                                                              *
  3. *   HEADER FOR tester for XMSIF                                            *
  4. *   OS:      DOS                                                           *
  5. *   VERSION: 1.0                                                           *
  6. *   DATE:    12/08/91                                                      *
  7. *                                                                          *
  8. *   Copyright (c) 1991 James W. Birdsall. All Rights Reserved.             *
  9. *                                                                          *
  10. *   Compiles under Borland C++ 2.0, TC 2.0, and MSC 6.00A.                 *
  11. *                                                                          *
  12. *   Header file for XMSTEST.                                               *
  13. *                                                                          *
  14. ***************************************************************************/
  15.  
  16. #ifndef XMSIF_H
  17.     **** ERROR **** MUST INCLUDE XMSIF.H BEFORE XMSTEST.H
  18. #endif
  19.  
  20. #ifndef XMSTEST_H
  21. #define XMSTEST_H
  22.  
  23. /*
  24. ** system includes <>
  25. */
  26.  
  27. /* include appropriate file according to compiler */
  28. #ifdef __TURBOC__
  29.  
  30. #include <alloc.h>
  31.  
  32. #else
  33.  
  34. #include <malloc.h>
  35.  
  36. #endif
  37.  
  38.  
  39. /*
  40. ** custom includes ""
  41. */
  42.  
  43. /*
  44. ** local #defines
  45. */
  46.  
  47. /* header and trailer messages for each test */
  48. #define TESTHEADER()     printf(">>>TEST #%d: %s\n", testno++, gblmsg)
  49. #define TESTTAILER()     printf("Test passed.\n")
  50.  
  51. /* minimum amount of extended memory free */
  52. #define MINFREE          81920L
  53.  
  54. /*
  55. ** This macro is for return checking for functions which are expected
  56. ** to succeed. It makes function calls to check if
  57. **      1) the function returned XMMOOPS
  58. **      2) the function returned a value that isn't XMMOOPS or 0
  59. **      3) the function set _XMMerror to an unexpected value
  60. ** The parameters are:
  61. **      fu  - char *, name of the function
  62. **      st  - status value returned by the function
  63. **      ex  - expected value of _XMMerror
  64. **      fr1 - conventional memory pointer to be freed on emergency exit
  65. **      fr2 - XMS handle to be freed on emergency exit
  66. **      fr3 - another XMS handle to be freed on emergency exit
  67. */
  68. #define TRIPLECHECK(fu, st, ex, fr1, fr2, fr3) \
  69.                          failcheck((fu), (st), (fr1), (fr2), (fr3)); \
  70.                          weirdretchk((fu), (st), (fr1), (fr2), (fr3)); \
  71.                          weirdcodechk((fu), (ex), (fr1), (fr2), (fr3))
  72.  
  73. /*
  74. ** Define LMALLOC() and LFREE() to the appropriate functions, according to
  75. ** compiler.
  76. */
  77. #ifdef __TURBOC__
  78.  
  79. #define LMALLOC(kbytes)         farmalloc((((unsigned long) kbytes) * 1024L))
  80. #define LFREE(ptr)              farfree((ptr))
  81.  
  82. #else
  83.  
  84. #define LMALLOC(kbytes)         halloc((kbytes), 1024)
  85. #define LFREE(ptr)              hfree((ptr))
  86.  
  87. #endif
  88.  
  89. /*
  90. ** assorted defines for the copy tests
  91. */
  92.  
  93. #define UCF                      unsigned char far
  94.  
  95. #define HALFLEN                  ((unsigned int) (MINFREE / 2L))
  96.  
  97. #define GUARDVAL                 0x55
  98.  
  99. /*
  100. ** Checks to see if a region of memory is still incrementing word values,
  101. ** handles cleanup and exit if not.
  102. */
  103. #define WORDCHECK(buf, len, msg)                                \
  104.     if (lfarincwordcheck((UCF *) (buf), (len), 0) != 0) {       \
  105.         printf("Copy corrupted %s.\n", (msg)); XMMfree(handle); \
  106.         LFREE(realbuf); exit(3); }
  107.  
  108. /*
  109. ** Check source and destination buffers, respectively.
  110. */
  111. #define SRCWORDCHECK(buf, len)    WORDCHECK(buf, len, "source buffer")
  112. #define CPYWORDCHECK(buf, len)    WORDCHECK(buf, len, "copied bytes")
  113.  
  114. /*
  115. ** Checks to see if a region of memory is still filled with a given value,
  116. ** handles cleanup and exit if not.
  117. */
  118. #define MEMCHECK(buf, len, val)                           \
  119.     if (lfarmemcheck((UCF *) (buf), (len), (val)) != 0) { \
  120.         printf("Copy corrupted destination.\n");          \
  121.         XMMfree(handle); LFREE(realbuf); exit(3); }
  122.  
  123. /*
  124. ** Checks buffer for nonzero values.
  125. */
  126. #define ZEROCHECK(buf, len)       MEMCHECK(buf, len, '\0')
  127.  
  128. /*
  129. ** Compares two regions of memory, handles cleanup and exit if not the same.
  130. */
  131. #define MEMCMP(buf1, buf2, len)                                           \
  132.     if (LFMEMCMP((void far *) (buf1), (void far *) (buf2), (len)) != 0) { \
  133.         printf("Copy corrupted copied bytes.\n"); XMMfree(handle);        \
  134.         LFREE(realbuf); exit(3); }
  135.  
  136. /*
  137. ** Checks guard zones to see if values changed
  138. */
  139. #define GUARDCHECK(han)                                 \
  140.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||   \
  141.         (farmemcheck(guard2, 1024, GUARDVAL) != 0) ||   \
  142.         (farmemcheck(guard3, 1024, GUARDVAL) != 0)) {   \
  143.             printf("Copy corrupted guard buffers.\n");  \
  144.             XMMfree((han)); LFREE(realbuf); exit(3); }
  145.  
  146.  
  147. /*
  148. ** misc: copyright strings, version macros, etc.
  149. */
  150.  
  151. /*
  152. ** typedefs
  153. */
  154.  
  155. /*
  156. ** global variables
  157. */
  158.  
  159. /*
  160. ** static globals
  161. */
  162.  
  163. /*
  164. ** function prototypes
  165. */
  166.  
  167. extern int  do_alloc_tests(unsigned long bytes);
  168. extern void do_rawcall_tests(void);
  169. extern void do_copy_tests(void);
  170. extern void do_ncopy1_tests(void);
  171. extern void do_icopy_tests(void);
  172. extern void do_UMB_tests(void);
  173.  
  174. extern unsigned long test_XMMcoreleft(void);
  175. extern unsigned long test_XMMallcoreleft(void);
  176. extern int test_XMMalloc(unsigned long bytes);
  177. extern void test_XMMfree(int handle);
  178.  
  179. extern void weirdretchk(char *function, int status, void far *tofree1,
  180.                                                      int tofree2, int tofree3);
  181. extern void weirdcodechk(char *function, int expected, void far *tofree1,
  182.                                                      int tofree2, int tofree3);
  183. extern void failcheck(char *function, int status, void far *tofree1,
  184.                                                      int tofree2, int tofree3);
  185. extern void nofailcheck(char *function, int status, void far *tofree1,
  186.                                                      int tofree2, int tofree3);
  187.  
  188. #endif
  189.  
  190.